package Control;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;

import Model.Wereld;
import View.LuchtruimView;
import View.Overview;

public class ButtonControl extends JPanel{

	private JButton up, down, left, right, stationair;
	private GridLayout layout;
	private Wereld wereld;
	private ButtonListener buttonListener;
	private Font font;
	private LuchtruimView luchtruimView;
	private KeyControl keyControl;

	
	public ButtonControl(Wereld wereld)
	{
		this.wereld = wereld;
		layout = new GridLayout(3,3);
		layout.setHgap(4);
		layout.setVgap(4);
		setBackground(Color.GREEN.darker().darker().darker().darker());
		setLayout(layout);
		setFocusable(true);
		setPreferredSize(new Dimension(150, 100));
		font = new Font("Serif", Font.BOLD, 18);
		
		buttonListener = new ButtonListener();
		up = new JButton("N");
		up.setFont(font);
		up.setBackground(Color.green);
		up.addActionListener(buttonListener);
		down = new JButton("Z");
		down.setFont(font);
		down.setBackground(Color.green);
		down.addActionListener(buttonListener);
		left = new JButton("W");
		left.setFont(font);
		left.setBackground(Color.green);
		left.addActionListener(buttonListener);
		right = new JButton("O");
		right.setFont(font);
		right.setBackground(Color.green);
		right.addActionListener(buttonListener);
		stationair = new JButton("X");
		stationair.setFont(font);
		stationair.setBackground(Color.green);
		stationair.addActionListener(buttonListener);

		add(new JLabel(""));
		add(up);
		add(new JLabel(""));
		add(left);
		add(stationair);
		add(right);
		add(new JLabel(""));
		add(down);
		add(new JLabel(""));
	}
	
	class ButtonListener implements ActionListener
	{
		public void actionPerformed(ActionEvent e) {
			if(e.getSource() == up)
			{
				wereld.move(0, -.1);
			}
			if(e.getSource() == down)
			{
				wereld.move(0, .1);
			}
			if(e.getSource() == left)
			{
				wereld.move(-.1, 0);
			}
			if(e.getSource() == right)
			{
				wereld.move(.1, 0);
			}
			if(e.getSource() == stationair)
			{
				wereld.stopHeli();
			}
		}
		
	}

}
